#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

#define err_exit(MSG) (perror(MSG),exit(1))

char buf1[]="abcdefghij";
char buf2[]="ABCDEFGHIJ";

int main(){
    int fd;
    if((fd=open("file.hole",O_WRONLY|O_CREAT,0644))<0){
        err_exit("Open file error!");
    }
    if(write(fd,buf1,10)!=10){
        err_exit("write error!");
    }
    //当前文件位置为10现在将他移到40
    if(lseek(fd,40,SEEK_SET)==-1){
        err_exit("lseek error");
    }
    if(write(fd,buf2,10)!=10){
        err_exit("write error!");
    }
    //现在文件位置为50
}